package com.dora.basic.basic.lambda;

/**
 * 匿名内部类lambda示例
 *
 * @author hanchen
 * @date 2025/02/06
 */
public class LambdaExampleForAnonymousInnerClass {
    public static void main(String[] args) {
        // 使用匿名内部类
        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                System.out.println("Hello from Runnable!");
            }
        };
        r1.run();  // 输出 "Hello from Runnable!"

        // 使用 Lambda 表达式
        Runnable r2 = () -> System.out.println("Hello from Runnable using Lambda!");
        r2.run();  // 输出 "Hello from Runnable using Lambda!"
    }
}
